#include "MkPtzCommand.h"

CMkPtzCommand CMkPtzCommand::m_Instance;
CMkPtzCommand::CMkPtzCommand()
{
    m_MapPtzCommand["PtzStop"] = MkPtzStop;
    m_MapPtzCommand["PtzUp"] = MkPtzUp;
    m_MapPtzCommand["PtzDown"] = MkPtzDown;
    m_MapPtzCommand["PtzLeft"] = MkPtzLeft;
    m_MapPtzCommand["PtzRight"] = MkPtzRight;
    m_MapPtzCommand["PtzZoomIn"] = MkPtzZoomIn;
    m_MapPtzCommand["PtzZoomOut"] = MkPtzZoomOut;
    m_MapPtzCommand["PtzFocusNear"] = MkPtzFocusNear;
    m_MapPtzCommand["PtzFocusFar"] = MkPtzFocusFar;
    m_MapPtzCommand["PtzApertureOpen"] = MkPtzApertureOpen;
    m_MapPtzCommand["PtzApertureClose"] = MkPtzApertureClose;
    m_MapPtzCommand["PtzGotoPreset"] = MkPtzGotoPreset;
    m_MapPtzCommand["PtzSetPreset"] = MkPtzSetPreset;
    m_MapPtzCommand["PtzDelPreset"] = MkPtzDelPreset;
    m_MapPtzCommand["PtzLightTurnOn"] = MkPtzLightTurnOn;
    m_MapPtzCommand["PtzLightTurnOff"] = MkPtzLightTurnOff;
    m_MapPtzCommand["PtzWiperTurnOn"] = MkPtzWiperTurnOn;
    m_MapPtzCommand["PtzWiperTurnOff"] = MkPtzWiperTurnOff;
    m_MapPtzCommand["PtzFanTurnOn"] = MkPtzFanTurnOn;
    m_MapPtzCommand["PtzFanTurnOff"] = MkPtzFanTurnOff;
    m_MapPtzCommand["PtzHeaterTurnOn"] = MkPtzHeaterTurnOn;
    m_MapPtzCommand["PtzHeaterTurnOff"] = MkPtzHeaterTurnOff;
    m_MapPtzCommand["PtzAuxTurnOn"] = MkPtzAuxTurnOn;
    m_MapPtzCommand["PtzAuxTurnOff"] = MkPtzAuxTurnOff;
    m_MapPtzCommand["PtzLeftUp"] = MkPtzLeftUp;
    m_MapPtzCommand["PtzRightUp"] = MkPtzRightUp;
    m_MapPtzCommand["PtzLeftDown"] = MkPtzLeftDown;
    m_MapPtzCommand["PtzRightDown"] = MkPtzRightDown;
    m_MapPtzCommand["PtzHorseCtorAutoScan"] = MkPtzHorseCtorAutoScan;
    m_MapPtzCommand["PtzVerseCtorAutoScan"] = MkPtzVerseCtorAutoScan;
    m_MapPtzCommand["PtzCruiseFillPre"] = MkPtzCruiseFillPre;
    m_MapPtzCommand["PtzCruiseSetDwell"] = MkPtzCruiseSetDwell;
    m_MapPtzCommand["PtzCruiseSetSpeed"] = MkPtzCruiseSetSpeed;
    m_MapPtzCommand["PtzCruiseClearPre"] = MkPtzCruiseClearPre;
    m_MapPtzCommand["PtzCruiseRun"] = MkPtzCruiseRun;
    m_MapPtzCommand["PtzCruiseClear"] = MkPtzCruiseClear;
    m_MapPtzCommand["Ptz3DZoom"] = MkPtz3DZoom;
}

Uint32 CMkPtzCommand::GetPtzCommand(const MkString& PtzCmd, MkPtzCommand& Cmd) const
{
    MkUnorderedMap<MkString, MkPtzCommand>::const_iterator it = m_MapPtzCommand.find(PtzCmd);
    if (it != m_MapPtzCommand.end()) {
        Cmd = it->second;
        return NoneError;
    }
    return InvalidParams;
}

Uint32 CMkPtzCommand::GetStrPtzCommand(const MkPtzCommand& MkCmd, MkString& strPtzCmd) const
{
    MkUnorderedMap<MkString, MkPtzCommand>::const_iterator it = m_MapPtzCommand.begin();
    for (; it != m_MapPtzCommand.end(); it++) {
        if (it->second == MkCmd) {
            strPtzCmd = it->first;
            return NoneError;
        }
    }
    return InvalidParams;
}


Uint32 CMkPtzCommand::SystemPtzControlToStateGridPtz(const MkPtzCommand& MkCmd,MkStateGridPtzCommandType& SgType)
{
    switch (MkCmd) {
    case MkPtzStop:
        SgType = MkStateGridPtzStop;
        break;
    case MkPtzUp:
        SgType = MkStateGridPtzUp;
        break;
    case MkPtzDown:
        SgType = MkStateGridPtzDown;
        break;
    case MkPtzLeft:
        SgType = MkStateGridPtzLeft;
        break;
    case MkPtzRight:
        SgType = MkStateGridPtzRight;
        break;
    case MkPtzLeftUp:
        SgType = MkStateGridPtzLeftUp;
        break;
    case MkPtzRightUp:
        SgType = MkStateGridPtzRightUp;
        break;
    case MkPtzLeftDown:
        SgType = MkStateGridPtzLeftDown;
        break;
    case MkPtzRightDown:
        SgType = MkStateGridPtzRightDown;
        break;
    case MkPtzHorseCtorAutoScan:
        SgType = MkStateGridPtzLinearSweep;
        break;
    case MkPtzVerseCtorAutoScan:
        SgType = MkStateGridPtzLinearSweep;
        break;
    case MkPtzZoomIn:
        SgType = MkStateGridPtzZoomIn;
        break;
    case MkPtzZoomOut:
        SgType = MkStateGridPtzZoomOut;
        break;
    case MkPtzFocusNear:
        SgType = MkStateGridPtzFocusNear;
        break;
    case MkPtzFocusFar:
        SgType = MkStateGridPtzFocusFar;
        break;
    case MkPtzApertureOpen:
        SgType = MkStateGridPtzApertuerOpen;
        break;
    case MkPtzApertureClose:
        SgType = MkStateGridPtzApertuerClose;
        break;
    case MkPtzLightTurnOn:
        SgType = MkStateGridPtzLightOn;
        break;
    case MkPtzLightTurnOff:
        SgType = MkStateGridPtzLightOff;
        break;
    case MkPtzWiperTurnOn:
        SgType = MkStateGridPtzWiperOn;
        break;
    case MkPtzWiperTurnOff:
        SgType = MkStateGridPtzWiperOff;
        break;
    case MkPtzFanTurnOn:
        break;
    case MkPtzFanTurnOff:
        break;
    case MkPtzHeaterTurnOn:
        SgType = MkStateGridPtzWarmOn;
        break;
    case MkPtzHeaterTurnOff:
        SgType = MkStateGridPtzWarmOff;
        break;
    case MkPtzAuxTurnOn:
    case MkPtzAuxTurnOff:
        break;
    case MkPtzGotoPreset:
        SgType = MkStateGridPtzCallPreset;
        break;
    case MkPtzSetPreset:
        SgType = MkStateGridPtzSetPreset;
        break;
    case MkPtzDelPreset:
        SgType = MkStateGridPtzDelPreset;
        break;
    case MkPtzCruiseFillPre:
        SgType = MkStateGridPtzCallPreset;
        break;
    case MkPtzCruiseSetDwell:
        SgType = MkStateGridPtzTrajectoryCruise;
        break;
    case MkPtzCruiseSetSpeed:
        break;
    case MkPtzCruiseClearPre:
        break;
    case MkPtzCruiseRun:
        break;
    case MkPtzCruiseClear:
        break;
    case MkPtz3DZoom:
        SgType = MkStateGridPtz3DZoom;
        break;
    default:
        break;
    }
    return NoneError;
}

Uint32 CMkPtzCommand::StateGridPtzControlToSystem(const MkStateGridPtzCommandType& SgType, MkPtzCommand& MkCmd)
{
    return NoneError;
}

CMkPtzCommand::~CMkPtzCommand()
{
}